import java.util.Arrays;

/**
 * Created with Interllij IDEA.
 * Descriptiption:
 * User: 王澄慧
 * Date: 2022-04-04
 * Time: 19:44
 */
public class FourDemo {
    public static int mun(int[] array){
        int sum = 0;
        for (int i = 0; i < array.length ; i++) {
            sum ^= array[i];
            }
        return sum;
        }
    public static void main(String[] args) {
        int[] array = {11,10,10,11,5};
        int num = mun(array);
        System.out.println(num);
    }
    public static void toString(int[] array){
            String newtoString = Arrays.toString(array);
            System.out.println(newtoString);
    }
    public static void main9(String[] args) {
        int[] array = {1,2,3,4,5};
        toString(array);
    }
    public static String fun1(int[] array){
        String a = "[";
        for (int x = 0;x < array.length;x++) {
            a += array[x];
            if(x != array.length-1){
                a += ",";
            }
        }
        a += "]";
        return a;
    }
    public static void main8(String[] args) {
        int[] array7 = {1,2,3,4,5};
        String a = fun1(array7);
        System.out.println(a);
    }
    public static int[] printArray1(int[] array){
        int i = 0;
        for (i = 0; i < 100; i++) {
            array[i] = i+1;
        }
        return array;
    }
    public static void main7(String[] args) {
        int[] arrar6 = new int[100];
        System.out.println(Arrays.toString(printArray1(arrar6)));
    }
    public static void printArray(int[] array){
        int i = 0;
        for (i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
    }
    public static void main6(String[] args) {
        int[] array5 = {1,2,3,4,5};
        printArray(array5);
    }
    public static int[] transform1(int[] array){
        for (int i : array ) {
            array[i] *= 2;
        }
        return array;
    }
    public static void main5(String[] args) {
        int[] array4 = {2,3,4,5,6};
        System.out.println(Arrays.toString(transform(array4)));
    }
    public static int[] transform(int[] array){
        int x = 0;
        for (x = 0;x < array.length;x++ ) {
            array[x] *= 2;
        }
        return array;
    }
    public static void main4(String[] args) {
        int[] arr = {1,2,3,4};
        System.out.println(Arrays.toString(transform(arr)));
    }
    public static int sum(int[] array){
        int sum = 0;
        for (int i: array) {
            sum += i;
        }
        return sum;
    }
    public static void main3(String[] args) {
        int[] array3 = {1,3,1,2,3};
        int fla = sum(array3);
        System.out.println(fla);
    }
    public static double avg1(int[] array){
        int sum = 0;
        for (int i = 0; i <= array.length; i++) {
            sum = sum+i;
        }
        return (1.0*sum/array.length);
    }
    public static void main2(String[] args) {
        int[] array = {1,2,3,4,5,6};
        double tem = avg1(array);
        System.out.println(tem);
    }
    public static double avg(int[] array){
        int sum = 0;
        for (int x: array) {
            sum += x;
        }
        return (double)sum /(double )array.length;
    }
    public static void main1(String[] args) {
        int[] array1 = {1,2,3,4,5};
        double flg = avg(array1);
        System.out.println(flg);
    }
}
